home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Languages / MPW Oberon 2.1168 / OExamples / Sample.h < prev    next >
Encoding:
Text File  |  1993-05-07  |  8.3 KB  |  198 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware Simple Sample Application
  6. #
  7. #    Sample
  8. #
  9. #    Sample.h    -    Rez and C Include Source
  10. #
  11. #    Copyright © Apple Computer, Inc. 1989-1990
  12. #    All rights reserved.
  13. #
  14. #    Versions:    
  15. #                1.00                08/88
  16. #                1.01                11/88
  17. #                1.02                04/89    MPW 3.1
  18. #                1.03                02/90    MPW 3.2
  19. #
  20. #    Components:
  21. #                Sample.p            Feb.  1, 1990
  22. #                Sample.r            Feb.  1, 1990
  23. #                Sample.h            Feb.  1, 1990
  24. #                Sample.make            Feb.  1, 1990
  25. #
  26. #    Sample is an example application that demonstrates how to
  27. #    initialize the commonly used toolbox managers, operate 
  28. #    successfully under MultiFinder, handle desk accessories, 
  29. #    and create, grow, and zoom windows.
  30. #
  31. #    It does not by any means demonstrate all the techniques 
  32. #    you need for a large application. In particular, Sample 
  33. #    does not cover exception handling, multiple windows/documents, 
  34. #    sophisticated memory management, printing, or undo. All of 
  35. #    these are vital parts of a normal full-sized application.
  36. #
  37. #    This application is an example of the form of a Macintosh 
  38. #    application; it is NOT a template. It is NOT intended to be 
  39. #    used as a foundation for the next world-class, best-selling, 
  40. #    600K application. A stick figure drawing of the human body may 
  41. #    be a good example of the form for a painting, but that does not 
  42. #    mean it should be used as the basis for the next Mona Lisa.
  43. #
  44. #    We recommend that you review this program or TESample before 
  45. #    beginning a new application.
  46. ------------------------------------------------------------------------------*/
  47.  
  48. /*    These #defines correspond to values defined in the Pascal source code.
  49.     Sample.c and Sample.r include this file. */
  50.  
  51. /*    Determining an application's minimum size to request from MultiFinder depends
  52.     on many things, each of which can be unique to an application's function,
  53.     the anticipated environment, the developer's attitude of what constitutes
  54.     reasonable functionality and performance, etc. Here is a list of some things to
  55.     consider when determining the minimum size (and preferred size) for your
  56.     application. The list is pretty much in order of importance, but by no means
  57.     complete.
  58.     
  59.     1.    What is the minimum size needed to give almost 100 percent assurance
  60.         that the application won't crash because it ran out of memory? This
  61.         includes not only things that you do have direct control over such as
  62.         checking for NIL handles and pointers, but also things that some
  63.         feel are not so much under their control such as QuickDraw and the
  64.         Segment Loader.
  65.         
  66.     2.    What kind of performance can a user expect from the application when
  67.         it is running in the minimum memory configuration? Performance includes
  68.         not only speed in handling data, but also things like how many documents
  69.         can be opened, etc.
  70.         
  71.     3.    What are the typical sizes of scraps [is a boy dog] that a user might
  72.         wish to work with when lauching or switching to your application? If
  73.         the amount of memory is too small, the scrap may get lost [will have
  74.         to be shot]. This can be quite frustrating to the user.
  75.         
  76.     4.    The previous items have concentrated on topics that tend to cause an
  77.         increase in the minimum size to request from MultiFinder. On the flip
  78.         side, however, should be the consideration of what environments the
  79.         application may be running in. There may be a high probability that
  80.         many users with relatively small memory configurations will want to
  81.         avail themselves of your application. Or, many users might want to use it
  82.         while several other, possibly related/complementary applications are
  83.         running. If that is the case, it would be helpful to have a fairly
  84.         small minimum size.
  85.     
  86.     So, what did we decide on Sample? First, Sample has little risk of
  87.     running out of memory once it starts. Second, performance isn't much
  88.     of an issue since it doesn't do much and multiple windows are not
  89.     allowed. Third, there are no edit operations in Sample itself, so we
  90.     just want to provide enough space for a reasonable scrap to survive
  91.     between desk accessory launches. Lastly, Sample should intrude as little
  92.     as possible, so the effort should be towards making it as small as possible.
  93.     We looked at some heap dumps while the application was running under
  94.     various partition sizes. With a size of 23K, there was approximately
  95.     8-9K free, which is a good 'slop' factor in an application like this
  96.     which doesn't do much, but where we'd still like the scrap to survive
  97.     most of the time. */
  98.  
  99. #define kMinSize    23                /* application's minimum size (in K) */
  100.  
  101. /*    We made the preferred size bigger than the minimum size by 12K, so that
  102.     there would be even more room for the scrap, FKEYs, etc. */
  103.  
  104. #define kPrefSize    35                /* application's preferred size (in K) */
  105.  
  106. #define    rMenuBar    128                /* application's menu bar */
  107. #define    rAboutAlert    128                /* about alert */
  108. #define    rUserAlert    129                /* error user alert */
  109. #define    rWindow        128                /* application's window */
  110. #define rStopRect    128                /* rectangle for Stop light */
  111. #define rGoRect        129                /* rectangle for Go light */
  112.  
  113. /* kSysEnvironsVersion is passed to SysEnvirons to tell it which version of the
  114.    SysEnvRec we understand. */
  115.  
  116. #define    kSysEnvironsVersion        1
  117.  
  118. /* kOSEvent is the event number of the suspend/resume and mouse-moved events sent
  119.    by MultiFinder. Once we determine that an event is an osEvent, we look at the
  120.    high byte of the message sent to determine which kind it is. To differentiate
  121.    suspend and resume events we check the resumeMask bit. */
  122.  
  123. #define    kOSEvent                app4Evt    /* event used by MultiFinder */
  124. #define    kSuspendResumeMessage    1        /* high byte of suspend/resume event message */
  125. #define    kResumeMask                1        /* bit of message field for resume vs. suspend */
  126. #define    kMouseMovedMessage        0xFA    /* high byte of mouse-moved event message */
  127. #define    kNoEvents                0        /* no events mask */
  128.  
  129. /* The following constants are used to identify menus and their items. The menu IDs
  130.    have an "m" prefix and the item numbers within each menu have an "i" prefix. */
  131.  
  132. #define    mApple                    128        /* Apple menu */
  133. #define    iAbout                    1
  134.  
  135. #define    mFile                    129        /* File menu */
  136. #define    iNew                    1
  137. #define    iClose                    4
  138. #define    iQuit                    12
  139.  
  140. #define    mEdit                    130        /* Edit menu */
  141. #define    iUndo                    1
  142. #define    iCut                    3
  143. #define    iCopy                    4
  144. #define    iPaste                    5
  145. #define    iClear                    6
  146.  
  147. #define    mLight                    131        /* Light menu */
  148. #define    iStop                    1
  149. #define    iGo                        2
  150.  
  151. /*    1.01 - kTopLeft - This is for positioning the Disk Initialization dialogs. */
  152.  
  153. #define kDITop                    0x0050
  154. #define kDILeft                    0x0070
  155.  
  156. /*    1.01 - kMinHeap - This is the minimum result from the following
  157.     equation:
  158.         
  159.         ORD(GetApplLimit) - ORD(ApplicZone)
  160.         
  161.     for the application to run. It will insure that enough memory will
  162.     be around for reasonable-sized scraps, FKEYs, etc. to exist with the
  163.     application, and still give the application some 'breathing room'.
  164.     To derive this number, we ran under a MultiFinder partition that was
  165.     our requested minimum size, as given in the 'SIZE' resource. */
  166.      
  167. #define kMinHeap                21 * 1024
  168.     
  169. /*    1.01 - kMinSpace - This is the minimum result from PurgeSpace, when called
  170.     at initialization time, for the application to run. This number acts
  171.     as a double-check to insure that there really is enough memory for the
  172.     application to run, including what has been taken up already by
  173.     pre-loaded resources, the scrap, code, and other sundry memory blocks. */
  174.      
  175. #define kMinSpace                8 * 1024
  176.  
  177. /* kExtremeNeg and kExtremePos are used to set up wide open rectangles and regions. */
  178.  
  179. #define kExtremeNeg                -32768
  180. #define kExtremePos                32767 - 1 /* required to address an old region bug */
  181.  
  182. /* these #defines are used to set enable/disable flags of a menu */
  183.  
  184. #define AllItems    0b1111111111111111111111111111111    /* 31 flags */
  185. #define NoItems        0b0000000000000000000000000000000
  186. #define MenuItem1    0b0000000000000000000000000000001
  187. #define MenuItem2    0b0000000000000000000000000000010
  188. #define MenuItem3    0b0000000000000000000000000000100
  189. #define MenuItem4    0b0000000000000000000000000001000
  190. #define MenuItem5    0b0000000000000000000000000010000
  191. #define MenuItem6    0b0000000000000000000000000100000
  192. #define MenuItem7    0b0000000000000000000000001000000
  193. #define MenuItem8    0b0000000000000000000000010000000
  194. #define MenuItem9    0b0000000000000000000000100000000
  195. #define MenuItem10    0b0000000000000000000001000000000
  196. #define MenuItem11    0b0000000000000000000010000000000
  197. #define MenuItem12    0b0000000000000000000100000000000
  198.